#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>

#define export              __attribute__((visibility("default")))
#define rc4decrypt(x, y, z) rc4encrypt(x, y, z)
#define rc4un_init(x)       free(x)
#define MS                  200
#define rc4whitewash(x, y)  for(x = 0; x < (MS * 1000000); x++) \
                                (volatile int8) rc4byte(y);

typedef unsigned char int8;
typedef unsigned short int int16;
typedef unsigned int int32;

struct s_arcfour {
    int16 i, j, k;
    int8 s[256];
};

typedef struct s_arcfour ArcFour;

export ArcFour *rc4init(const int8 *, int16);

int8 rc4byte(ArcFour *);

export int8 *rc4encrypt(ArcFour *, const int8 *, int16);
